﻿using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using ZH.Infrastructure.Dto.Request.Mobile;
using ZH.Infrastructure.Dto.Request.Order;
using ZH.Service.Interface;

namespace ZH.Api.Admin.Controllers.Cashier

{
    /// <summary>
    /// 收银端·订单
    /// </summary>
    public class C_OrderController : BaseController
    {
        private readonly I_Order_Service _order_Service;
        private readonly I_Mobile_Service _mobile_Service;

        public C_OrderController(I_Login_Service login_Service, I_Order_Service order_Service,I_Mobile_Service mobile_Service) : base(login_Service) 
        {
            _order_Service = order_Service;
            _mobile_Service = mobile_Service;
        }

        /// <summary>
        /// 获取订单列表
        /// </summary>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Get_Cashier_Order() 
        {
            var result = await _order_Service.Get_Cashier_Order();

            return Ok(result);
        }

        /// <summary>
        /// 生成订单
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> Cashier_Add_Order(Order_Cashier_Request_Dto dto)
        {
            var result = await _order_Service.Cashier_Add_Order(dto);

            return Ok(result);
        }


        /// <summary>
        /// 获取单个顾客
        /// </summary>
        /// <param name="phone"></param>
        /// <returns></returns>
        [HttpGet]
        public async Task<IActionResult> Get_Cashier_Single_Mobile(string phone)
        {
            var result = await _mobile_Service.Get_Cashier_Single_Mobile(phone);

            return Ok(result);
        }

        /// <summary>
        /// 新增客户
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPost]
        public async Task<IActionResult> Cashier_Add_Mobile(Mobile_Cashier_Request_Dto dto)
        {
            var result = await _mobile_Service.Cashier_Add_Mobile(dto);

            return Ok(result);
        }

        /// <summary>
        /// 订单中的服务项目完成后
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<IActionResult> Cashier_Order_Service_Completed(Service_Completed dto)
        {
            var result = await _order_Service.Cashier_Order_Service_Completed(dto);

            return Ok(result);
        }

        /// <summary>
        /// 订单结算后
        /// </summary>
        /// <param name="dto"></param>
        /// <returns></returns>
        [HttpPut]
        public async Task<IActionResult> Cashier_Order_Settlement(Order_Settlement dto)
        {
            var result = await _order_Service.Cashier_Order_Settlement(dto);

            return Ok(result);
        }
    }
}
